//
//  NSObject+NXFilter.m
//  OAManager
//
//  Created by kepuna on 2017/12/12.
//  Copyright © 2017年 kepuna. All rights reserved.
//

#import "NSObject+NXFilter.h"

@implementation NSObject (NXFilter)

+ (NSString *)nx_filterWhiteSpaceInText:(NSString *)text {
    return [text stringByReplacingOccurrencesOfString:@"\n" withString:@""];
}

+ (NSString *)nx_filterEmojiInText:(NSString *)text {
    if (text == nil) {
        return @"";
    }
    
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"[^\\u0020-\\u007E\\u00A0-\\u00BE\\u2E80-\\uA4CF\\uF900-\\uFAFF\\uFE30-\\uFE4F\\uFF00-\\uFFEF\\u0080-\\u009F\\u2000-\\u201f\r\n]" options:NSRegularExpressionCaseInsensitive error:nil];
    NSString *modifiedString = [regex stringByReplacingMatchesInString:text
                                                               options:0
                                                                 range:NSMakeRange(0, [text length])
                                                          withTemplate:@""];
    
    return modifiedString;
}

+ (NSString *)nx_replacePhoneNumWithStar:(NSString *)text {
    return [text stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
}

@end
